<?php

require_once 'lib/dbappinclude.php';

$sql = "SELECT user_id FROM user WHERE user_id = $user";
$result = mysql_query($sql) or die(mysql_error());

if (mysql_num_rows($result) <= 0)
{
	$query = "SELECT name FROM user WHERE uid = $user";
	$array = $facebook->api_client->fql_query($query);

	$username = $array[0]['name'];

	$sql = "INSERT INTO user (user_id, user_name, user_1st, user_2nd, user_3rd, user_4th, user_all) " .
		   "VALUES ('$user', '$username', 0, 0, 0, 0, 0)";
	mysql_query($sql) or die(mysql_error());
}

$query = "SELECT * FROM user WHERE user_id = $user";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);

$s1 = $row['user_1st'];
$s2 = $row['user_2nd'];
$s3 = $row['user_3rd'];
$s4 = $row['user_4th'];
$sa = $row['user_all'];

$query = "SELECT name, pic_square FROM user WHERE uid = $user";
$array = $facebook->api_client->fql_query($query);

$nam = $array[0]['name'];
$pic = $array[0]['pic_square'];

?>

<fb:swf
swfbgcolor="000000"
imgstyle="border-width:3px; border-color:white;"
swfsrc="http://chodaidi.ikoaguild.com/main.swf"
flashvars="u_name=<?php echo $nam ?>&u_pic=<?php echo $pic ?>"
width='600' height='450' />

